<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<body class="gray-bg">
<div class="ui-layout-west">
    <div class="main-content">
        <div class="box box-main" style="width: 3000px">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa icon-grid"></i> 终端列表
                </div>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;">
                        <i class="fa fa-chevron-up"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠">
                        <i class="fa fa-chevron-down"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新">
                        <i class="fa fa-refresh"></i></button>
                </div>
            </div>
            <div class="ui-layout-content">
                <div id="tree" class="ztree" style="overflow: auto"></div>
            </div>
        </div>
    </div>
</div>
<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            LED显示编号:<input type="text" name="Led_id"/>
                        </li>
                        <li>
                            用户编号:<input type="text" name="uid"/>
                        </li>
                        <li>
                            终端号:<input type="text" name="tid"/>
                        </li>
                        <li>
                            是否有效：
                            <select name="remark" th:with="type=${@dict.getType('sys_yes_no')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <input class="laydate-icon  layer-date"
                                   name="createtime"
                                   id="createtime"
                                   value=""
                                   readonly="readonly"
                                   style="width:120px;"
                                   placeholder="创建时间"
                                   title="创建时间"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="iot:ledinfo:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="iot:ledinfo:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="iot:ledinfo:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="iot:ledinfo:export">
                <i class="fa fa-download"></i> 导出
            </a>
           <!-- <a class="btn btn-success" onclick="$.operate.exportExcelBySingle()" shiro:hasPermission="system:user:add">
                <i class="fa fa-plus"></i> 导出-->
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('iot:ledinfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('iot:ledinfo:remove')}]];
    var openFlag=[[${@permission.hasPermi('iot:ledinfo:open')}]];
    var closeFlag=[[${@permission.hasPermi('iot:ledinfo:close')}]];
    var datas = [[${@dict.getType('sys_yes_no')}]];
    var prefix = ctx + "iot/led";
    var aid1 = "";
    $(function() {
        $('body').layout({ west__size: 185 });
        queryAreaList();
        queryAreaTree();
    });
    function queryAreaList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            //sortName: "ledSort",
            modalName: "LED",
            search: false,
            showExport: true,
            columns: [
                {
                checkbox: true
            },
                {
                    field: 'led_id',
                    title: 'LED显示编号',
                    sortable: true
                },
                {
                    field: 'uid',
                    title: '用户编号',
                    sortable: true
                },
                {
                    field: 'tid',
                    title: '终端号',
                    sortable: true
                },
                {
                    field: 'content',
                    title: 'LED显示信息文字',
                },
                {
                    field: 'stardate',
                    title: '开始显示时间',
                    sortable: true
                },
                {
                    field: 'enddate',
                    title: '显示结束时间',
                    sortable: true
                },
                {
                    field: 'createtime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'effect',
                    title: '特效',
                },
                {
                    field: 'color',
                    title: '颜色',
                },
                {
                    field: 'demo',
                    title: '备注',
                },
                {
                    field: 'remark',
                    title: '是否有效',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + openFlag + '" href="#" onclick="href=\'/iot/led/open\'"><i class="fa fa-edit"></i>开灯</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + closeFlag + '" href="#" onclick="href=\'/iot/led/close\'"><i class="fa fa-remove"></i>关灯</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.led_id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.led_id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                },
                {
                    field: 'aname',
                    title: '地区',
                }
            ]
        };
        $.table.init(options);
    };
    function queryAreaTree(){
        var url = ctx + "system/dept/treeData";
        var options = {
            url: url,
            onClick : zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            aid1 = treeNode.id;
            $("#aid").val(treeNode.id);
            $.table.search();
        }
        $.tree.init(options);
    }
    $('#form-group11').on('change', function (e) {
        $("#form-group1").attr("name",$("#form-group11").val())
    });
    $('#form-group22').on('change', function (e) {
        $("#form-group2").attr("name",$("#form-group22").val())
    });
    $('#form-group33').on('select2:select', function (e) {
        $("#form-group3").attr("name",$("#form-group33").val())
    });
    $('#form-group44').on('change', function (e) {
        $("#form-group4").attr("value",$("#form-group44").val());
    });
</script>
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>
<script th:src="@{/js/plugins/layer/layui-v2.4.5/layui/layui.js}"></script>
<script>
    laydate({
        elem:"#createtime",
        event:"focus"
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem:"#LED",
            type: 'time',
        });
    });
</script>
</body>
</html>